package com.gxy.learn.design.model.behaviour.iterator;

import java.util.ArrayList;
import java.util.List;

/**
 * @description:
 * @author: gaoxueyong
 * @Date: 2022/11/8 21:46
 */
public class StudentAggregateImpl implements StudentAggregate {
    private List<Student> students = new ArrayList<>();

    /**
     * 添加对象
     *
     * @param student
     * @return void
     * @Author gaoxueyong
     * @Date 9:45 下午 2022/11/8
     * @Param [student]
     */
    @Override
    public void addStudent(Student student) {
        students.add(student);
    }

    /**
     * 修改对象
     *
     * @param student
     * @return void
     * @Author gaoxueyong
     * @Date 9:45 下午 2022/11/8
     * @Param [student]
     */
    @Override
    public void removefStudent(Student student) {
        students.remove(student);
    }

    /**
     * 获取对象迭代器
     *
     * @return com.gxy.learn.design.model.behaviour.iterator.StudentIterator
     * @Author gaoxueyong
     * @Date 9:45 下午 2022/11/8
     * @Param []
     **/
    @Override
    public StudentIterator getStudentIterator() {
        return new StudentIteratorImpl(students);
    }
}
